package com.rainbow.modules.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.rainbow.modules.sys.entity.DepartmentHeader;
import com.rainbow.modules.sys.mapper.DepartmentHeaderMapper;
import com.rainbow.modules.sys.service.DepartmentHeaderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 * Auth rainbow
 */
@Service
@Slf4j
@Transactional
public class DepartmentHeaderServiceImpl extends ServiceImpl<DepartmentHeaderMapper, DepartmentHeader> implements DepartmentHeaderService {

    @Override
    public List<String> findHeaderByDepartmentId(String departmentId, Integer type) {
        List<String> list = new ArrayList<>();
        List<DepartmentHeader> headers = list(new QueryWrapper<DepartmentHeader>().eq("department_id", departmentId).eq("type", type));
        headers.forEach(e -> {
            list.add(e.getUserId());
        });
        return list;
    }
}
